// 校园网络
#include<iostream>
#include<stack>
#include<vector>
using namespace std;
const int N = 1e4, M = 5e4;
vector<int> e[N];
stack<int> stk;
int dfn[N], low[N], instk[N], tot;
int scc_id[N], din[N], dout[N], sz[N], cnt, res;
int n, m;
void tarjan(int u){
    // 入栈，盖时间戳
    dfn[u] = low[u] = ++tot;
    stk.push(u);
    instk[u] = 1;
    for(auto v : e[u]){
        if(!dfn[v]) {
            tarjan(v);
            low[u] = min(low[u], low[v]);
        }else if(instk[v]){
            low[u] = min(low[u], dfn[v]);  
        }
    }
    if(dfn[u] == low[u]){
        cnt++;
        int v;
        do{
            v = stk.top();
            stk.pop();
            instk[v] = 0;
            scc_id[v] = cnt;
            sz[cnt]++;
        }while(u != v);
    }
}

int main(){
    cin >> n;
    m = 1;
    while(n --){
        int x;
        while(cin >> x, x){
            e[m].push_back(x);
        }
        m++;
    }
    
    for(int i = 1; i <= n; i++){
        if(!dfn[i]) tarjan(i);
    }
    for(int i = 1; i <= n; i++){
        for(auto j : e[i]){
            if(scc_id[i] != scc_id[j]){
                dout[scc_id[i]]++;
                din[scc_id[j]]++;
            }
        }
    }
    int dincnt=0, doutcnt=0;
    for(int i = 1; i <= cnt; i++){
        if(din[i] == 0) dincnt++;
        if(dout[i] == 0) doutcnt++;
    }
    cout << dincnt << endl;
    cout << max(dincnt, doutcnt) << endl;
}